// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import axios from 'axios'

Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: { App },
  template: '<App/>'
});


// function axiosA() {
//    return axios({
//        method:"get",
//        url:"http://httpbin.org/headers",
//    });
// }

//使用全局的axios和对应的配置在进行网络请求
// axios.defaults.baseURL = 'https://api.example.com';
// axios.defaults.timeout = 5000;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';


// function axiosB() {
//   return axios({
//       method:"get",
//       url:"http://httpbin.org/ip",
//   });
// }

// axios.all([axiosA(),axiosB()]).then(res=>{
//    console.log(res); //一个数组，保存了两次请求完成之后的响应数据
// });
//
// //res1,res2分别为axiosA,axiosB两个方法执行后的响应结果
// axios.all([axiosA(),axiosB()]).then(axios.spread((res1,res2)=>{
//    console.log(res1);
//    console.log(res2);
// }));


//创建对应的axios实例
const axios_instance = axios.create({
   baseURL : 'http://httpbin.org',
   timeout : 5000
});

axios_instance({
    method:"get",
    url:"/headers",
    params:{}
}).then(res=>{
    console.log(res);
});


